﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="xbrlesindus_ettevote", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(XbrlesindusEttevote))]
    public class XbrlesindusEttevoteSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IXbrlesindusEttevote clazz;
        
        public XbrlesindusEttevoteSerializer(IXbrlesindusEttevote clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("ariregistri_kood");
            if (clazz.AriregistriKood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.AriregistriKood))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("ettevotja_id");
            if (clazz.EttevotjaId!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.EttevotjaId))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("arinimi");
            if (clazz.Arinimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Arinimi))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("liik");
            if (clazz.Liik!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Liik))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Liik");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("staatus");
            if (clazz.Staatus!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Staatus))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Staatus");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("staatus_tekstina_est");
            if (clazz.StaatusTekstinaEst!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.StaatusTekstinaEst))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : StaatusTekstinaEst");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("staatus_tekstina_eng");
            if (clazz.StaatusTekstinaEng!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.StaatusTekstinaEng))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : StaatusTekstinaEng");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("piirkond");
            if (clazz.Piirkond!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Piirkond))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Piirkond");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("piirkond_tekstina_est");
            if (clazz.PiirkondTekstinaEst!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PiirkondTekstinaEst))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PiirkondTekstinaEst");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("piirkond_tekstina_eng");
            if (clazz.PiirkondTekstinaEng!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PiirkondTekstinaEng))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PiirkondTekstinaEng");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("majaasta_algus");
            if (clazz.MajaastaAlgus!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.MajaastaAlgus))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("majaasta_lopp");
            if (clazz.MajaastaLopp!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.MajaastaLopp))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("oigvorm");
            if (clazz.Oigvorm!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Oigvorm))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Oigvorm");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("oigvorm_tekstina_est");
            if (clazz.OigvormTekstinaEst!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.OigvormTekstinaEst))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : OigvormTekstinaEst");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("oigvorm_tekstina_eng");
            if (clazz.OigvormTekstinaEng!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.OigvormTekstinaEng))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : OigvormTekstinaEng");
            }
            Writer.WriteEndElement();
            if (clazz.KapitaliSumma!=null) {
                Writer.WriteStartElement("kapitali_summa");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "float");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdFloat(((float)(clazz.KapitaliSumma))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.KapitaliValuuta!=null) {
                Writer.WriteStartElement("kapitali_valuuta");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.KapitaliValuuta))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.KapitaliValuutaTekstinaEst!=null) {
                Writer.WriteStartElement("kapitali_valuuta_tekstina_est");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.KapitaliValuutaTekstinaEst))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.KapitaliValuutaTekstinaEng!=null) {
                Writer.WriteStartElement("kapitali_valuuta_tekstina_eng");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.KapitaliValuutaTekstinaEng))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="ariregistri_kood") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.AriregistriKood = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("ariregistri_kood")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesindus_ettevote>ariregistri_kood", Reader.LocalName);
            }
            if (Reader.LocalName=="ettevotja_id") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.EttevotjaId = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("ettevotja_id")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesindus_ettevote>ettevotja_id", Reader.LocalName);
            }
            if (Reader.LocalName=="arinimi") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Arinimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("arinimi")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesindus_ettevote>arinimi", Reader.LocalName);
            }
            if (Reader.LocalName=="liik") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>xbrlesindus_ettevote>liik");
                }
                clazz.Liik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("liik")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesindus_ettevote>liik", Reader.LocalName);
            }
            if (Reader.LocalName=="staatus") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>xbrlesindus_ettevote>staatus");
                }
                clazz.Staatus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("staatus")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesindus_ettevote>staatus", Reader.LocalName);
            }
            if (Reader.LocalName=="staatus_tekstina_est") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>xbrlesindus_ettevote>staatus_tekstina_est");
                }
                clazz.StaatusTekstinaEst = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("staatus_tekstina_est")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesindus_ettevote>staatus_tekstina_est", Reader.LocalName);
            }
            if (Reader.LocalName=="staatus_tekstina_eng") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>xbrlesindus_ettevote>staatus_tekstina_eng");
                }
                clazz.StaatusTekstinaEng = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("staatus_tekstina_eng")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesindus_ettevote>staatus_tekstina_eng", Reader.LocalName);
            }
            if (Reader.LocalName=="piirkond") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>xbrlesindus_ettevote>piirkond");
                }
                clazz.Piirkond = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("piirkond")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesindus_ettevote>piirkond", Reader.LocalName);
            }
            if (Reader.LocalName=="piirkond_tekstina_est") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>xbrlesindus_ettevote>piirkond_tekstina_est");
                }
                clazz.PiirkondTekstinaEst = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("piirkond_tekstina_est")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesindus_ettevote>piirkond_tekstina_est", Reader.LocalName);
            }
            if (Reader.LocalName=="piirkond_tekstina_eng") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>xbrlesindus_ettevote>piirkond_tekstina_eng");
                }
                clazz.PiirkondTekstinaEng = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("piirkond_tekstina_eng")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesindus_ettevote>piirkond_tekstina_eng", Reader.LocalName);
            }
            if (Reader.LocalName=="majaasta_algus") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.MajaastaAlgus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("majaasta_algus")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesindus_ettevote>majaasta_algus", Reader.LocalName);
            }
            if (Reader.LocalName=="majaasta_lopp") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.MajaastaLopp = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("majaasta_lopp")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesindus_ettevote>majaasta_lopp", Reader.LocalName);
            }
            if (Reader.LocalName=="oigvorm") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>xbrlesindus_ettevote>oigvorm");
                }
                clazz.Oigvorm = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("oigvorm")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesindus_ettevote>oigvorm", Reader.LocalName);
            }
            if (Reader.LocalName=="oigvorm_tekstina_est") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>xbrlesindus_ettevote>oigvorm_tekstina_est");
                }
                clazz.OigvormTekstinaEst = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("oigvorm_tekstina_est")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesindus_ettevote>oigvorm_tekstina_est", Reader.LocalName);
            }
            if (Reader.LocalName=="oigvorm_tekstina_eng") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>xbrlesindus_ettevote>oigvorm_tekstina_eng");
                }
                clazz.OigvormTekstinaEng = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("oigvorm_tekstina_eng")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>xbrlesindus_ettevote>oigvorm_tekstina_eng", Reader.LocalName);
            }
            if (Reader.LocalName=="kapitali_summa") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.KapitaliSumma = new global::Xtee.Core.Schema.XsdFloat(Reader.ReadElementString("kapitali_summa")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="kapitali_valuuta") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.KapitaliValuuta = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("kapitali_valuuta")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="kapitali_valuuta_tekstina_est") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.KapitaliValuutaTekstinaEst = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("kapitali_valuuta_tekstina_est")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="kapitali_valuuta_tekstina_eng") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.KapitaliValuutaTekstinaEng = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("kapitali_valuuta_tekstina_eng")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
        }
    }
}
